import  React  from  "react";
import  "../css/board.css";
import  eventEmitter from  "../event"
class  board  extends  React.Component{
    constructor(props){
        super(props);
        this.state ={
            list:[]
        }
    }
  componentDidMount(){
    eventEmitter.addListener("sendMessageTooBoard",(message)=>{
        this.state.list.push(message);
         this.setState({
           list:this.state.list
         })
    })
  }
    render() {
        return (
           <div className="box1">
              {
                  this.state.list.map((element,index)=>{
                    return(
                        <div className="content">
                             <p>{element.a}楼说：</p>
                            <p>留言内容：{element.content}</p>
                    <p>留言时间：{element.date}</p>
                        </div>
                    )
                  })
              }
           </div>
        )
    }
}
export   default  board;